//
//  UserInfoController.m
//  HB
//
//  Created by 陶秋安 on 16/5/12.
//  Copyright © 2016年 孙智慧. All rights reserved.
//

#import "UserInfoController.h"
#import "UserInfoOperation.h"
#import "UserInfoHeadImg.h"
#import "ChoosePhoto.h"

@implementation UserInfoController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self loadUserInfo];
    
    _tvUserInfo.delegate=self;
    
    _tvUserInfo.dataSource=self;
    
    _tvUserInfo.scrollEnabled=NO;
    
}

-(void)setNavigationLeft:(NSString *)imageName sel:(SEL)sel
{
    
}

- (void)setNavigationRight:(NSString *)imageName sel:(SEL)sel
{
    
}

- (void)setNavigationTitleImage:(NSString *)imageName
{
    self.navigationItem.title = @"个人信息";
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if(indexPath.row==0)
    {
 
         ChoosePhoto *choosePhoto=[self.storyboard instantiateViewControllerWithIdentifier:@"ChoosePhoto"];
        [self.navigationController pushViewController:choosePhoto animated:YES];
    }
}

-(void)loadUserInfo
{
    dict= [_db queryData];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *idefine=@"userinfo_headimg";
    
    UserInfoHeadImg *cell = [tableView dequeueReusableCellWithIdentifier:idefine];
    
    if (cell==nil)
    {
        cell = [[UserInfoHeadImg alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:idefine];
    }
    
    if(indexPath.row==0)
    {
        cell.lblTitle.text=@"头像";
        
        cell.lblValue.hidden=YES;
        
        cell.imgHead .layer.cornerRadius=2;
        
        cell.imgHead .clipsToBounds=true;
        
        [Common downLoadImageByURL:cell.imgHead andURL:[dict objectForKey:@"headImgUrl"] andName:[dict objectForKey:@"headImgName"]];
        
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
        
    }
    else if(indexPath.row==1)
    {
        cell.lblTitle.text=@"昵称";
        
        cell.imgHead.hidden=YES;
        
        cell.lblValue.text=[dict objectForKey:@"nickName"];
        
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
    }
    else
    {
        cell.lblTitle.text=@"手机号";
 
        cell.imgHead.hidden=YES;
        
        cell.lblValue.text=@"13898648031";
 
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
    }
    return  cell;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row==0)
    {
        return 84;
    }
    return 34;
}

@end
